<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/include/page.jsp" %>
<!DOCTYPE html>
<html lang="zh-CN">
	<head>
		<title>朝代列表 - ssm</title>
		<%@ include file="/common/include/title.jsp" %>
		<script type="text/javascript">
			/**
				点击链接,实现分页;
					~点击链接,把当前页和每页多少条;这个值修改一下
					~通过js,让表单提交;
				@param currentPage 当前页
				@param pageSize	每页多少条
			*/
			function pageFormSubmit(formId,currentPage,currentPageId,pageSize,pageSizeId)
			{
				console.info(currentPage + "==pageFormSubmit===" + pageSize);
				$("#" + currentPageId).val(currentPage);
				$("#" + pageSizeId).val(pageSizeId);
				/* 提交表单 */
				$("#" + formId).submit();
				/* return false:可以阻止事件;
					点击a链接;默认的效果是打开href指定的网址;
					只要return false ; 这个打开网址的单击事件就被阻止了
				*/
				return false ; 
			}
		</script>
	</head>
	<body>
		<%@ include file="/common/include/header.jsp" %>
		<!-- 网页的主体部分 -->
		<div class="container">
			<div class="row">
				<div class="col-md-11 col-sm-offset-1">
					<h2 class="sub-header">朝代列表</h2>
	
					<form action="${rootPath }/head/demo/dynastyList.htm" method="post" class="form-inline">
						<label for="keyword">关键字:</label>
						<input type="text" name="keyword" value="${requestScope.keyword }" class="form-control mr-sm-2">
						<label for="keyword">状态:</label>
						<select name="status" class="form-control mr-sm-2">
							<option value="">请选择</option>
							<option value="1" ${requestScope.status == '1' ? 'selected' : '' }>启用</option>
							<option value="0" ${requestScope.status == '0' ? 'selected' : '' }>禁用</option>
						</select>
						<label for="email">发布时间:</label>
						<input type="text" name="st" value="${requestScope.st }" readonly="true" class="form-control mr-sm-2" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="Wdate"/>
						-->
						<input type="text" name="ed" value="${requestScope.ed }" readonly="true" class="form-control mr-sm-2" onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="Wdate"/>
						<input type="submit" class="btn btn-primary" value="搜索">
						<a href="${rootPath }/head/demo/dynastyInsert.htm" class="btn btn-primary ml-2" target="_blank">添加</a>
					</form>
				</div>
				<div class="col-md-11 col-sm-offset-1">
					<div class="table-responsive mt-2">
						<table class="table table-striped table-hover">
							<thead>
								<tr>
									<th>序号</th>
									<th>名称</th>
									<th title="开国时间">开时</th>
									<th title="亡国时间">亡时</th>
									<th>国祚</th>
									<th>首都</th>
									<th>状态</th>
									<th>更新时间</th>
									<th>发布时间</th>
									<th>操作</th>
								</tr>
							</thead>
							<tbody>
								<c:forEach items="${requestScope.demoDynastyList}" var="demoDynasty" varStatus="stat">
									<tr>
										<td>${stat.count }</td>
										<td>${demoDynasty.name }</td>
										<td>${demoDynasty.stYear }</td>
										<td>${demoDynasty.edYear }</td>
										<td>${demoDynasty.guoZuo }</td>
										<td>${demoDynasty.capital}</td>
										<td>
											<c:choose>
												<c:when test="${demoDynasty.status == '1'}">启用</c:when>
												<c:when test="${demoDynasty.status == '0'}">禁用</c:when>
											</c:choose>
										</td>
										<td><fmt:formatDate value="${demoDynasty.updateTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
										<td><fmt:formatDate value="${demoDynasty.pubTime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
										<td>
											<a href="${rootPath }/head/demo/dynastyUpdate.htm?id=${demoDynasty.id}" target="_blank">修改</a>
										</td>
									</tr>
								</c:forEach>
							</tbody>
						</table>
					</div>
				</div>
				<div class="col-md-11 col-sm-offset-1">
					<form id="pageForm" action="${rootPath }/head/demo/dynastyList.htm"
						method="post" class="form-inline col-md-11 col-sm-offset-1">
						<!-- 设置一些参数 -->
						<input type="hidden" name="keyword" value="${requestScope.keyword }">
						<input type="hidden" name="status" value="${requestScope.status }">
						<input type="hidden" name="st" value="${requestScope.st }">
						<input type="hidden" name="ed" value="${requestScope.ed }">
	
						<nav aria-label="Page navigation example">
							<ul class="pagination justify-content-end">
								<li class="page-item">
									<%-- <a href="${rootPath }/head/demo/dynastyList.htm?currentPage=1&pageSize=${requestScope.pageInfoUtil.pageSize }&keyword=${requestScope.keyword }&status=${requestScope.status }&st=${requestScope.st }&ed=${requestScope.ed }" 
										class="page-link" onclick="return pageFormSubmit()">
										<span>首页</span>
									</a> --%>
									<a href="" class="page-link" onclick="return pageFormSubmit('pageForm','1','currentPage','${requestScope.pageInfoUtil.pageSize }','pageSizeId')">
										<span>首页</span>
									</a>
								</li>
								<li class="page-item">
									<a href="" class="page-link" onclick="return pageFormSubmit('pageForm','${requestScope.pageInfoUtil.prePage }','currentPage','${requestScope.pageInfoUtil.pageSize }','pageSizeId')">
										<span>上一页</span>
									</a>
								</li>
								<li class="page-item">
									<a href="" class="page-link" onclick="return pageFormSubmit('pageForm','${requestScope.pageInfoUtil.nextPage }','currentPage','${requestScope.pageInfoUtil.pageSize }','pageSizeId')">
										<span>下一页</span>
									</a>
								</li>
								<li class="page-item">
									<a href="" class="page-link" onclick="return pageFormSubmit('pageForm','${requestScope.pageInfoUtil.totalPage }','currentPage','${requestScope.pageInfoUtil.pageSize }','pageSizeId')">
										<span>尾页</span>
									</a>
								</li>
								<li class="page-item">共${requestScope.pageInfoUtil.totalPage }页,共${requestScope.pageInfoUtil.totalRecord }条</li>
								<li class="page-item">
									第<input type="text" id="currentPage" name="currentPage" class="form-control" value="${requestScope.pageInfoUtil.currentPage }" size="5" maxlength="5"/>页
								</li>
								<li class="page-item">
									<input type="text" id="pageSize" name="pageSize" class="form-control" value="${requestScope.pageInfoUtil.pageSize }" size="5" maxlength="5"/>
								</li>
								<li class="page-item"><input type="submit" value="GO" class="form-control btn btn-primary"/></li>
							</ul>
						</nav>
					</form>
				</div>
			</div>
		</div>
		<%@ include file="/common/include/footer.jsp" %>
	</body>
</html>